package com.pos43.business.service.impl;

import java.util.List;

import com.pos43.business.dao.IOrderItemDao;
import com.pos43.business.dao.IOrdersDao;
import com.pos43.business.dao.IProductDao;
import com.pos43.business.dao.impl.OrderItemDao;
import com.pos43.business.dao.impl.OrdersDao;
import com.pos43.business.dao.impl.ProductDao;
import com.pos43.business.service.IOrderItemService;
import com.pos43.domain.OrderItem;
import com.pos43.domain.Orders;
import com.pos43.domain.Product;

public class OrderItemService implements IOrderItemService{

	IOrdersDao orderDao = new OrdersDao();
	IOrderItemDao orderItemDao = new OrderItemDao();
	IProductDao productDao = new ProductDao();
	
	public Integer addOrderItem(Orders order, Product product, Integer count){
		OrderItem orderItemInstance = new OrderItem();
		orderItemInstance.setOrder(order);
		orderItemInstance.setProduct(product);
		orderItemInstance.setCount(count);
		return orderItemDao.save(orderItemInstance);
	}
	
	public void delOrderItem(Integer order_id, Integer product_id){
		orderItemDao.delete(order_id, product_id);
	}
	
	public void delOrderItem(OrderItem orderItem){
		orderItemDao.delete(orderItem);
	}
	
	public void updateOrderItem(OrderItem orderItem){
		orderItemDao.update(orderItem);
	}
	
	public List<OrderItem> listOrderItem(){
		return orderItemDao.findAll();
	}
	
	public OrderItem getOrderItem(Integer order_id, Integer product_id){
		return orderItemDao.get(order_id, product_id);
	}
	

	public List<OrderItem> getOrderItemList(Integer id) {
		return orderItemDao.findById(id);
	}
	
	
	public IOrdersDao getOrdersDao() {
		return orderDao;
	}

	public void setOrdersDao(IOrdersDao orderDao) {
		this.orderDao = orderDao;
	}

	public void setTeacherDao(IOrdersDao  orderDao) {
		this.orderDao = orderDao;
	}

	public IOrderItemDao getOrderItemDao() {
		return orderItemDao;
	}

	public void setOrderItemDao(IOrderItemDao orderItemDao) {
		this.orderItemDao = orderItemDao;
	}



}
